# -*- coding: utf-8 -*-
# @Author   : niejiali
# @Time     : 2019/1/16 8:52
# @File     : __init__.py.py
# @Software : PyCharm
from app.app import Flask


def register_blueprints(app):
    # 注册蓝图
    from app.api.v1 import create_blueprint_v1
    app.register_blueprint(create_blueprint_v1(), url_prefix='/v1')


def register_plugin(app):
    from app.models.base import db
    db.init_app(app)
    with app.app_context():
        db.create_all()


def create_app():
    app = Flask(__name__)
    app.config.from_object('app.config.setting')
    app.config.from_object('app.config.secure')
    register_blueprints(app)
    register_plugin(app)
    return app
